﻿//bibaoke.com

using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;

namespace Less.WebBrowserQuery
{
    internal class FilterByAll : ElementFilter
    {
        protected override IEnumerable<HtmlElement> EvalThis(HtmlDocument document)
        {
            return document.All.Cast<HtmlElement>();
        }

        protected override IEnumerable<HtmlElement> EvalThis(HtmlDocument document, IEnumerable<HtmlElement> source)
        {
            if (document.IsNotNull())
            {
                return source.SelectMany(i => i.All.Cast<HtmlElement>());
            }
            else
            {
                return source.SelectMany(i => i.Children.Cast<HtmlElement>());
            }
        }
    }
}
